#include "HideShoot.h"


CHideShoot::CHideShoot()
{
	isHide = true;
	loadSprites();
}

CHideShoot::CHideShoot(D3DXVECTOR3 position)
{
	isHide = true;
	this->position_ = position;
	loadSprites();
}

CHideShoot::~CHideShoot()
{
}

int CHideShoot::setStatus()
{
	return 0;
}
float CHideShoot::getAngleWithPlayer(D3DXVECTOR3 playerPosition)
{
	// nothing to write down here
	return 0;
}
void CHideShoot::AI(D3DXVECTOR3 playerPosition)
{
	static	DWORD timeShootForHide = 0;
	static	DWORD timeShoot = 0;
			DWORD now = 0;
	if (pow((playerPosition.x - this->getPosition().x), 2) <= 400*400) // Screen side
		isBeginShoot = true;
	else
		isBeginShoot = false;

	if (isBeginShoot)
	{
		if (isHide)
		{
			now = GetTickCount();
			if (now - timeShootForHide > 2000)
			{
				isHide = false;
				timeShoot = GetTickCount();
			}
		}
		else
		{
			now = GetTickCount();
			if (now - timeShoot > 2000)
				isHide = true;
			timeShootForHide = GetTickCount();
		}
	}
}

int CHideShoot::HealthyState()
{
	return 0;
}

void CHideShoot::loadSprites()
{
	spriteVector_.push_back(new CSprite(L"Enemy//BOT3.png", 1, 3, 3));
}

void CHideShoot::Update(DWORD deltaTime)
{
	
}

void CHideShoot::Render()
{
	if (isBeginShoot)
	{
		if (isHide)
			spriteVector_[0]->Render(2, 3, this->position_);
		else
			spriteVector_[0]->Render(1, 2, this->position_);
	}
}